﻿using System;

namespace JXT.PrimaryKey.Batman.Core.Security
{
    /// <summary>
    /// 用户登录Membeship接口
    /// </summary>
    public interface IMembership
    {
        /// <summary>
        ///  用户拥有的所有真实权限数组
        /// </summary>
        Authority[] Authorities { get; }

        /// <summary>
        /// 用户状态cookie对象
        /// </summary>
        SecurityCookie Cookie { get; }

        /// <summary>
        /// 用户状态session对象
        /// </summary>
        SessionUser Session { get; }

        /// <summary>
        /// 过期时间
        /// </summary>
        DateTime? Expires { get; }

        /// <summary>
        /// 用户是否已经登录
        /// </summary>
        bool IsLogin { get; }

        /// <summary>
        /// 登录系统
        /// </summary>
        /// <param name="name">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="expired">过期时间</param>
        /// <returns>登陆是否成功</returns>
        bool LoginByName(string name, string password, DateTime? expired = null);

        /// <summary>
        /// 登录系统
        /// </summary>
        /// <param name="mail">用户邮箱</param>
        /// <param name="password">密码</param>
        /// <param name="expired">过期时间</param>
        /// <returns>登陆是否成功</returns>
        bool LoginByMail(string mail, string password, DateTime? expired = null);

        /// <summary>
        /// 退出登录
        /// </summary>
        void Logout();

        /// <summary>
        /// 重新载入状态信息
        /// </summary>
        void Reload();
    }
}
